package platform.bio.server;

import platform.bio.ChannelAdapter;
import platform.bio.ChannelHandler;

import java.net.Socket;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Date;

public class BioServerHandler extends ChannelAdapter {
    public BioServerHandler(Socket socket, Charset charset) {
        super(socket, charset);
    }

    @Override
    public void channelActive(ChannelHandler ctx) {
        System.out.println("连接报告本地地址："+ctx.socket().getLocalAddress());
        ctx.writeAndFlush("服务端连接通知抽象类\r\n");
    }


    @Override
    public void channelRead(ChannelHandler ctx, Object msg) {
        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " 接收到消息：" + msg);
        ctx.writeAndFlush("服务端已收到消息\r\n");
    }
}
